<?php

class TpropertyController extends CommonController{
	
	private $_model;
	
	public function __init(){
		
		$this->_model=K('tproperty');
	}
	
	
	public function index(){
			
		$data=$this->_model->get_all_data(array('tid'=>Q('get.tid')));
		$this->assign('data',$data);
		
		$this->display();
		
	}
	public function add(){
		
		if(IS_POST){
			
			if(!$this->_model->add_data()) $this->error($this->_model->error);
			
			$this->success('添加成功');
			
		}
		
		$this->display();
	}
	
	
	public function del(){
		
		$this->_model->delete_data(array('tpid'=>Q('get.tpid')));
		
		
		
		$this->success('删除成功');
	}
	
	public function edit(){
		
		if(IS_POST){
			if(!$this->_model->edit_data(array('tpid'=>Q('get.tpid')))) $this->error($this->_model->error);
			
			$this->success('修改成功');
		}
		
		$tpid=Q('get.tpid');
		
		$data=$this->_model->get_one_data(array('tpid'=>$tpid));
		
		$this->assign('data',$data);
		
		$this->display();
	}
	
	
}